import { get } from '@/http/axios'
import { Store } from 'vuex'
import { getWbiKeys,encWbi } from '@/api/getVideo'

export { default as topBox } from '@/layout/Top/index.vue'
export { default as upTitleBox } from '../layout/upTitleBox.vue'
export { default as tagsBox } from '../layout/tagsBox.vue' 
export { default as biliOfficial } from '../layout/biliOfficial.vue'  
export { default as biliUpInfo } from '../layout/biliUpInfo.vue'  
export { default as upLiveRoom } from '../layout/upLiveRoom.vue'
export { default as noticeBox } from '../layout/noticeBox.vue'  
export { default as upElec } from '../layout/upElec.vue'  
export { default as upVideoBox } from '../layout/upVideoBox.vue'  
export { default as topping } from '../layout/topping.vue'  
export { default as videoList } from '../layout/videoList.vue'  
export { default as articlesList } from '../layout/articlesList.vue'  
export { default as represBox } from '../layout/represBox.vue'  



let video = {
    pn:1,
    ps:25,
    index:1,
    order:'pudate',
    order_avoided:'true',
    platform:'web',
    web_location:'1550101'
}
let stow = {
    pn:1,
    ps:10
}
let bangumi = {
    type:1
}
let coinVideo = {
    gaia_source:'main_web',
    web_location:'333.999'
}

const map = new Map()
map.set('video',{ url: '/x/space/wbi/arc/search?mid=', params: video })
map.set('stow',{ url: '/x/v3/fav/folder/created/list?up_mid=', params: stow })
map.set('bangumi',{ url: '/x/space/bangumi/follow/list?vmid=', params: bangumi })
map.set('coinVideo',{ url: '/x/space/coin/video?vmid=', params: coinVideo })
map.set('likeVideo',{ url: '/x/space/like/video?vmid=', params: coinVideo })

export function baseDiffTypeInitData(store:Store<any>,mid:number,type:string = 'video',order?:string){
    if (order) {
        map.set('video',{ url:'/x/space/wbi/arc/search?mid=', params:{ ...video,order }});
    }
    const wbi_keys = getWbiKeys(store)
    const query = encWbi(
        {
            ...map.get(type).params,

       },
            wbi_keys.img_key, 
            wbi_keys.sub_key
       )
    return new Promise((resolve,rej) => {
        get(map.get(type).url + mid + '&' + query).then(res => {
            resolve(res)
        }).catch(err => {
            rej('报错啦')
        })
    }) 
}
